package com.test

class User {
	String login
	String password
	String role = "user"
	boolean isAdmin = false
	
    static constraints = {
		login blank:false, nullable:false, unique:true
		password blank:false, password:true 
		role(inList:["user", "admin"]) 
    }
	
	static transients = ['admin']
	/*boolean isAdmin = {
		return role == "admin"
	//	return true
	}*/
	
	def beforeInsert = {
		password = password.encodeAsSHA()
	}
		
	String toString() {
		login
	};
}
